package main

import (
	"fmt"
)

func main() {
	var x = 2147483647
	res := reverse(x)
	fmt.Print(res)
}

const MAX_INT = 2147483647
const MIN_INT = -2147483648

func reverse(x int) int {
	var sum int = 0
	for x != 0 {
		if sum < MIN_INT/10 || sum > MAX_INT/10 {
			return 0
		}
		sum = sum * 10
		sum += x % 10
		x = x / 10
	}
	return sum
}
